/*
 * @Author: lyx 2858535420@qq.com
 * @Date: 2023-03-10 15:50:23
 * @LastEditors: lyx 2858535420@qq.com
 * @LastEditTime: 2023-03-10 16:02:16
 * @FilePath: /antd-vue2-template/config/get-less-letiables.js
 * @Description: 获取主题样式
 * 
 * file 文件名
 */
const fs = require('fs');

module.exports = function getLessletiables(file) {
    let themeContent = fs.readFileSync(file, 'utf-8');
    let letiables = {};
    themeContent.split('\n').forEach(function (item) {
        if (item.indexOf('//') > -1 || item.indexOf('/*') > -1) {
            return;
        }

        let _pair = item.split(':');
        if (_pair.length < 2) return;
        let key = _pair[0].replace('\r', '').replace('@', '');
        if (!key) return;
        let value = _pair[1].replace(';', '').replace('\r', '').replace(/^\s+|\s+$/g, '');
        letiables[key] = value;
    });
    return letiables;
};
